/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gameheart.server;

/**
 *
 * @author win7
 */
public class ServerCard implements Comparable<ServerCard> {
    private int diem;
    public ServerCard()
    {
        
    }
    public ServerCard(Type type, int diem)
    {
        this.diem = diem;
        this.type = type;
    }
    /**
     * @return the diem
     */
    public int getDiem() {
        return diem;
    }

    /**
     * @param diem the diem to set
     */
    public void setDiem(int diem) {
        this.diem = diem;
    }

    /**
     * @return the type
     */
    public Type getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(Type type) {
        this.type = type;
    }
    public int compareTo(ServerCard o) {
        int realDiemHienTai = diem;
        if(realDiemHienTai == 0)
        {
            realDiemHienTai = 13;
        }
        int diemLoaiCardHienTai = type.ordinal() * 13 + realDiemHienTai;
        int realDiemCardKhac = o.getDiem();
        if(realDiemCardKhac == 0)
        {
            realDiemCardKhac = 13;
        }
        int diemLoaiCardKhac = o.getType().ordinal() * 13 + realDiemCardKhac;
        if(diemLoaiCardKhac == diemLoaiCardHienTai)
        {
            return 0;
        }
        else

        {
            if(diemLoaiCardKhac > diemLoaiCardHienTai )
            {
                return -1;
            }
        }
        return 1;
    }
    public enum Type{Bit, Chuong, Ro, Co};
    private Type type;

}
